package com.yixun.qfbao.hander;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yixun.qfbao.api.service.ResourcesService;
import com.yixun.qfbao.apidto.GetMenuReqDto;
import com.yixun.qfbao.apidto.GetMenuResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.GetMenuReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;

/**
 * 获取菜单
 * 
 * @author Administrator
 * 		
 */
@Service("getMenuHander")
public class GetMenuHander extends CommonAbstractHander {
	private static Logger logger= LoggerFactory.getLogger(GetMenuHander.class);
	
	@Autowired
	private ResourcesService resourcesService;
	
	@Override
	public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
		GetMenuReqVo req = (GetMenuReqVo)reqDto;
		GetMenuReqDto reqDto1 = req.getParams();
		BaseResponseDTO<GetMenuResDto> res = new BaseResponseDTO<>();
		GetMenuResDto resDto = new GetMenuResDto();
		try {
			resDto = resourcesService.getMenu(reqDto1);
			res.setResData(resDto);
			res.setResult(resDto.getResult());
		} catch (Exception e) {
			logger.error("GetMenuHander error: {}", e);
			resDto.setResult(ResultEnum.FAIL.getNo());
			resDto.setResultMsg("用户未设置菜单,无法使用!");
		}
		return res;
	}
	
}
